#include <iostream>
#include <unordered_map>

using namespace std;

class Solution {
public:
    string fractionToDecimal(int numerator, int denominator) {
        int64_t numerator_64 = numerator;
        int64_t denominator_64 = denominator;
        string result;
        if ((int64_t) numerator_64 * denominator_64 < 0) {
            result = "-";
            numerator_64 = abs(numerator_64);
            denominator_64 = abs(denominator_64);
        }
        int64_t quotient = numerator_64 / denominator_64;
        int64_t remainder = numerator_64 - denominator_64 * quotient;
        result += to_string(quotient);
        if (remainder == 0) {
            return result;
        }
        result += ".";
        unordered_map<int, int> quotient_map;
        while (1) {
            unordered_map<int, int>::iterator it = quotient_map.find(remainder);
            if (it != quotient_map.end()) {
                result = result.substr(0, it->second) + "(" + result.substr(it->second, result.size() - it->second) + ")";
                return result;
            }
            quotient_map.insert({remainder, result.length()});
            remainder *= 10;
            quotient = remainder / denominator_64;
            remainder = remainder - quotient * denominator_64;
            if (remainder == 0) {
                result += to_string(quotient);
                return result;
            }
            result += to_string(quotient);
        }
    }
};

int main() {
    Solution solution;
    int numerator = -1;
    int denominator = 2147483648;
    string out = solution.fractionToDecimal(numerator, denominator);
    cout << out << endl;
}

